package Entity;

import java.io.IOException;
import java.util.List;

/**
 * 主程序：测试实验核心功能（习题生成、练习、批改）
 */
public class Main {
    public static void main(String[] args) {
        try {
            // 1. 初始化习题生成器（单例）
            ExerciseGenerator generator = ExerciseGenerator.getInstance();
            String generateDate = "20231001"; // 习题生成日期
            int exerciseCount = 10; // 每套习题10道题

            // 2. 批量生成三类习题（加法、减法、混合）
            generator.generateAddExercises(exerciseCount, generateDate);
            generator.generateSubExercises(exerciseCount, generateDate);
            generator.generateMixExercises(exerciseCount, generateDate);

            // 3. 每天随机抽取3套习题（当前日期20231002）
            List<String> selectedExercises = generator.randomSelectThreeExercises("20231002");
            String targetExerciseFile = selectedExercises.get(0); // 选择第一套习题作为练习

            // 4. 小明开始练习
            PracticeManager practiceManager = new PracticeManager();
            String practiceFilePath = practiceManager.startPracticeByExerciseFile(targetExerciseFile);

            // 5. 小明完成部分习题，保存进度（示例：完成第1题和第3题）
            practiceManager.savePracticeProgress(practiceFilePath, "Add_20231001_001_001", 50); // 假设正确答案50
            practiceManager.savePracticeProgress(practiceFilePath, "Add_20231001_001_003", 25); // 假设正确答案25

            // 6. 自动批改练习
            Corrector corrector = new Corrector();
            corrector.correctPractice(targetExerciseFile, practiceFilePath);

        } catch (IOException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            System.out.println("错误：" + e.getMessage());
        }
    }
}